package com.flight.trans.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flight.trans.R;
import com.flight.trans.base.BaseRecyclerAdapter;
import com.flight.trans.base.BaseViewHolder;
import com.flight.trans.bean.EnterPortWarehousingBean.EnterPortWarehousingData;
import com.flight.trans.util.CommonUtils;

import java.util.List;

/**
 * 进港入库
 */
public class EnterPortWarehousingAdapter extends BaseRecyclerAdapter<EnterPortWarehousingData> {

    public EnterPortWarehousingAdapter(Context mContext, List<EnterPortWarehousingData> mList) {
        super(mContext, mList);
    }

    @Override
    public int setContentView() {
        return R.layout.adapter_enter_port_warehousing;
    }

    @Override
    protected void bindData(BaseViewHolder holder, EnterPortWarehousingData data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);

        TextView mTvFlightNumber = holder.findViewById(R.id.mTvFlightNumber);
        TextView mTvFlightDate = holder.findViewById(R.id.mTvFlightDate);
        TextView mTvAta = holder.findViewById(R.id.mTvAta);
        TextView mTvRouteLine = holder.findViewById(R.id.mTvRouteLine);
        TextView mTvTotalCount = holder.findViewById(R.id.mTvTotalCount);
        TextView mTvTotalWeight = holder.findViewById(R.id.mTvTotalWeight);
        TextView mTvTallyManager = holder.findViewById(R.id.mTvTallyManager);
        TextView mTvTallyTime = holder.findViewById(R.id.mTvTallyTime);

        mTvFlightNumber.setText(data.getFlightNo());
        mTvFlightDate.setText(data.getFldt());
        mTvAta.setText(CommonUtils.getTimeNorm(data.getAta()));
        mTvRouteLine.setText(data.getFlightCourseCode());
        mTvTotalCount.setText(String.valueOf(data.getNum()));
        mTvTotalWeight.setText(String.valueOf(data.getWeight()));
        mTvTallyManager.setText(data.getDispatchUserName());
        mTvTallyTime.setText(CommonUtils.getTimeNorm(data.getInOrderFinishDate()));

        mLlContainerItem.setBackground(mContext.getDrawable(data.isLocked() ? R.color.color_red : R.drawable.selector_cyan_line));

        setItemClickListener(mLlContainerItem , position);
    }
}
